package cn.ad.param;

import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 广告主查询参数
 * @author Administrator
 */
public class AdvertiserQuery extends AbstractPagingSortParam{

	/**
	 * 广告主ID
	 */
	private Integer id;

	/**
	 * 搜索关键词， 广告住名称或者ID
	 */
	private String search;

	/**
	 * 代理商ID
	 */
	private Integer agencyId;

	private Boolean platform;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @return the search
	 */
	public String getSearch() {
		return search;
	}

	/**
	 * @param search the search to set
	 */
	public void setSearch(String search) {
		this.search = search;
	}

	public Integer getAgencyId() {
		return agencyId;
	}

	public void setAgencyId(Integer agencyId) {
		this.agencyId = agencyId;
	}

	public Boolean getPlatform() {
		return platform;
	}

	public void setPlatform(Boolean platform) {
		this.platform = platform;
	}

	/**
	 * 默认按id排序
	 */
	@Override
	public String getSortby() {
		return StringUtils.isEmpty(super.getSortby()) ? "id" : super.getSortby();
	}

	/**
	 * 默认按降序排序
	 */
	@Override
	public ORDER getOrder() {
		return super.getOrder() == null ? ORDER.desc : super.getOrder();
	}

	public Map<String,Object> getSearchMap(){
		Map<String,Object> map=new HashMap<>();
		map.put("id",this.getId());
		map.put("offset",this.getOffset());
		map.put("limit",this.getLimit());
		map.put("order",this.getOrder());
		map.put("sortby",this.getSortby());
		map.put("agencyId",this.getAgencyId());
		map.put("platform",this.getPlatform());
		map.put("key",this.getSearch());
		return map;
	}
}
